package com.yunchao.feature.base.domain.utils

import android.annotation.SuppressLint
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.regex.Pattern

fun formatPhoneNumberWithRegex(phoneNumber: String): String {
    if (phoneNumber.isEmpty()) {
        return ""
    }
    val pattern = Pattern.compile("(\\d{3})\\d{4}(\\d{4})")
    val matcher = pattern.matcher(phoneNumber)
    return if (matcher.matches()) {
        matcher.replaceAll("$1****$2")
    } else {
        phoneNumber
    }
}


@SuppressLint("NewApi")
fun getCurrentTime(): String {
    // 获取当前时间
    val currentDateTime = LocalDateTime.now()

    // 定义日期时间格式化模式
    val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")

    // 将当前时间按照指定格式进行格式化
    val formattedDateTime = currentDateTime.format(formatter)

    // 输出格式化后的时间
    return formattedDateTime
}